<?php
require_once('Config.php');
require_once('User.php');
require_once('MsgStack.php');
session_start();


$msg = new MsgStack();
$user = new User();

if($_GET['id']!=""){
  $sql = "Select * from user where id=".$_GET['id'];
  $res = mysql_query($sql);
  if($res){
    while($row=mysql_fetch_array($res)){
      $user->setId($row['id']);
      $user->setUsername($row['username']);
      $user->setRealname($row['realname']);
      $user->setEmail($row['email']);
    }
  }
  else{
    $msg->put("Cannot get user from database.");
    $_SESSION['USER_NOT_FOUND']=$msg->getMsg("Cannot get user from database.");
    header("Location:userManage.php?msg=USER_NOT_FOUND");
  }
}else{ 
  $msg->push("User not found!");
  $_SESSION['USER_NOT_FOUND']=$msg->getMsg();
  header("Location:userManage.php?msg=USER_NOT_FOUND");
}
?>

<html>
  <head>
    <title>
      Add User !
    </title>
    <link href="css/admin-common.css" rel="stylesheet" type="text/css">
    <script type="text/javascript" src="../js/jquery.js">
    </script>
    <script type="text/javascript" src="js/common.js">
    </script>
  </head>
  <body>
    <h3>User Management : Add User</h3>
    <hr/>
    <p>
      <label>
        <Strong><a href="userManage.html">&lt; Back to User Account List Page</a></Strong>
      </label>
    </p>
    <!--Here is the message from server when page load-->
    <div class="sessionMessage">
    </div>
    <!--Session Message End-->

    <!--Add User Form-->
    <form action="addUser.php" method="post">
      <label>
        <span>*RealName:</span>
        <input type="text" id="realname" name="realname" value="<?php echo $user->getRealname();?>"/>
      </label>
      <label>
        <span>*UserName:</span>
        <input type="text" id="username" name="username" value="<?php echo $user->getUsername();?>"/>
      </label>
      <p>
      <input type="hidden" name="ifChangePsw" name="ifChangePsw"/>
      <label style="color:#ff9900">Just leave them blank if don't want to change password</label>
      <label>
        <span>(*)New Password:</span>
        <input type="password" id="passwod" name="password" /> 
      </label>
      <label>
        <span>(*)New Password again:</span>
        <input type="password" id="password2" name="password2" />
      </label>
      </p>
       <label>
        <span>*Email:</span>
        <input type="text" id="email" name="email"  value="<?php echo $user->getEmail(); ?>"/>
      </label>
      <label>
        <span></span>
         
      </label>
      <p>
        <label>
          <span>&nbsp;</span>
       
       <button class="btn btn-style-1" type="submit"><b><b>Submit</b></b></button> </label>
      </p>
    </form>
  </body>
  <script type="text/javascript">
    var app={
      init: function() {
      },
      validForm:function(){
      if(password)
      
      }

    }
  </script>
</html>
